const express = require("express");
const port = 8888;
const app = express();
const data = require("./route");

//---------------解决------------------>
app.all("*", function (req, res, next) {
  res.header("Access-Control-Allow-Origin", "*");
  res.header("Access-Control-Allow-Headers", "*");
  res.header("Access-Control-Allow-Methods", "*");
  res.header("Content-Type", "application/json;charset=utf-8");
  next();
});

// 退出登录
app.get("/test", (req, res) => {
  // 前端传过来的数据
  setTimeout(() => {
    res.send({
      data,
    });
  }, 500);
});

app.listen(port, () => {
  console.log(`端口${port}运行中....`);
});
